﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;

using Husb.Data;
using Husb.DataUtil;

using GroundWater.Data;
using WaterSourceTable = GroundWater.Data.InfoDataSet.WaterSourceDataTable;
using WaterSourceRow = GroundWater.Data.InfoDataSet.WaterSourceRow;

namespace GroundWater.DataAccess
{
    public class WaterSourceDataAdapter : DataAccessAdapter<InfoDataSet, WaterSourceTable, WaterSourceRow>
    {
        public WaterSourceDataAdapter()
        {
            this.TableName = "WaterSource";

            GetAllStoredProc = SqlStatements.WaterSource_FetchAll;
            InsertStoredProc = SqlStatements.WaterSource_Insert;
            UpdateStoredProc = SqlStatements.WaterSource_Update;
            DeleteStoredProc = SqlStatements.WaterSource_Delete;

            GetByIdStoredProc = SqlStatements.WaterSource_FetchById;
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Code", DbType.String, "Code", DataRowVersion.Current);
            db.AddInParameter(cmd, "Name", DbType.String, "Name", DataRowVersion.Current);
            db.AddInParameter(cmd, "Grade", DbType.String, "Grade", DataRowVersion.Current);
            db.AddInParameter(cmd, "AdministrativeDivisionsCode", DbType.String, "AdministrativeDivisionsCode", DataRowVersion.Current);
            db.AddInParameter(cmd, "ResourceRegionCode", DbType.String, "ResourceRegionCode", DataRowVersion.Current);

            db.AddInParameter(cmd, "FunctionRegionCode", DbType.String, "FunctionRegionCode", DataRowVersion.Current);
            db.AddInParameter(cmd, "ProjectScale", DbType.String, "ProjectScale", DataRowVersion.Current);
            db.AddInParameter(cmd, "BuildState", DbType.String, "BuildState", DataRowVersion.Current);
            db.AddInParameter(cmd, "ProductDate", DbType.DateTime, "ProductDate", DataRowVersion.Current);
            db.AddInParameter(cmd, "ProjectRuningState", DbType.String, "ProjectRuningState", DataRowVersion.Current);

            db.AddInParameter(cmd, "ContinueState", DbType.String, "ContinueState", DataRowVersion.Current);
            db.AddInParameter(cmd, "SupplyPopulation", DbType.Decimal, "SupplyPopulation", DataRowVersion.Current);
            db.AddInParameter(cmd, "YearlyQuality", DbType.Decimal, "YearlyQuality", DataRowVersion.Current);
            db.AddInParameter(cmd, "DailyQuality", DbType.Decimal, "DailyQuality", DataRowVersion.Current);
            db.AddInParameter(cmd, "AdministrationAgency", DbType.String, "AdministrationAgency", DataRowVersion.Current);

            db.AddInParameter(cmd, "Administration", DbType.String, "Administration", DataRowVersion.Current);
            db.AddInParameter(cmd, "Note", DbType.String, "Note", DataRowVersion.Current);
        }

        protected override void PopulateStringIdParameters(Database db, DbCommand cmd, string id)
        {
            db.AddInParameter(cmd, "Code", DbType.String, id);// DbType.AnsiString
        }

        protected override void PopulateDeleteParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Code", DbType.String, "Code", DataRowVersion.Original);
        }
    }
}
